<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
    *{margin:0;padding:0;}
    #test{
        width:100px;
        height:100px;
        background: pink;
    }
    </style>
</head>
<body>
    <button id="btn">动画</button>
    <div id="test" style="left:0"></div>
    <script>
    // test-->left偏移200
    var timer=100;
    var btn=document.getElementById("btn");
    var test=document.getElementById("test");
    btn.onclick=function(){
        function go(){
            var valueleft=parseInt(test.style.left)+10;
            test.style.left=valueleft+"px";
            if(parseInt(test.style.left)<100){
                setTimeout(go.timer);                   
            }
        }
        go();
    }
    </script>
</body>
</html>